import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

// //引入ant
// import Antd from "ant-design-vue";
// import "ant-design-vue/dist/antd.css";
// Vue.use(Antd);

//引入element-ui  用于后台
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);

// 引入axios  用于发起网络请求
import axios from "axios";
import VueAxios from "vue-axios";
Vue.use(VueAxios, axios);

//引入moment.js 用于解析时间
import moment from "moment";
Vue.prototype.moment = moment;

//引入swiper  用于轮播图
import VueAwesomeSwiper from "vue-awesome-swiper";
// import style  引入轮播图样式
import "swiper/css/swiper.css";
Vue.use(VueAwesomeSwiper /* { default options with global component } */);

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");

// vue路由编程式跳转时进入新的页面，位置在顶部
router.beforeEach((to, from, next) => {
  // chrome
  document.body.scrollTop = 0;
  // firefox
  document.documentElement.scrollTop = 0;
  // safari
  window.pageYOffset = 0;
  next();
});
